package com.vicente.redisdemo.service;

import com.alibaba.fastjson.JSON;
import com.vicente.redisdemo.config.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RedisDemoServiceImpl implements  RedisDemoService{

    @Autowired
    private RedisUtil redisUtil;

    public String getRedisByKey(String key){
        Object oKey = redisUtil.get(key);
        String value = "找不到redis结果";
        if (oKey == null){
            redisUtil.set("redis-deom-666777","abcdefghi66666666666666666",60);
        }else {
            value = JSON.toJSONString(oKey);
        }
        return value;

    }
}
